<!DOCTYPE html>
<html>
<head>
<link href="./css/modern.css" rel="stylesheet">
<link href="./css/style-student-group.css" rel="stylesheet" type="text/css">
</head>

<script>
function validateTextFields()
{


	var course = document.forms[1]["Course"].value;
	var title = document.forms[1]["Title"].value;
	var section = document.forms[1]["Section"].value;
	var term = document.forms[1]["Term"].value;
	var year = document.forms[1]["Year"].value;
	var instructor = document.forms[1]["Instructor"].value;
	
	if(course == "" || course == null )
	{
		alert("Please fill in the Course Field!!");
		return false;
	}
	
	else if(title == "" || title == null)
	{
		alert("Please fill in the Title Field!!");
		return false;
	}
	else if(section == "" || section == null)
	{
		alert("Please fill in the Section Field!!");
		return false;
	}
	else if(term == "" || term == null)
	{
		alert("Please fill in the Term Field!!");
		return false;
	}
	else if(year == "" || year == null)
	{
		alert("Please fill in the Year Field!!");
		return false;
	}
	else if(instructor == "" || instructor == null)
	{
		alert("Please fill in the Instructor Field!!");
		return false;
	}
	
	return true;
}
</script>

	<%
		String firstname = (String) request.getAttribute("firstname");
		String lastname = (String) request.getAttribute("lastname");
		String isEmpty = (String) request.getAttribute("isEmpty");
	%>
<body>
	<div id="container">
		<div id="header">
			<br>
			<h1 id="main-title">
				<b><font color="000000">EECE Student Group Assessments</b></font>
			</h1>
			<h2>
				Welcome <%=firstname%> <%=lastname%>!
			</h2>
			<h3 align="right">Logout</h3>
		</div>
		<div id="body">
			<%if(isEmpty.equals("true")) {%>
				<div class="error(info, warning)-bar" id="messageDialog" align="center"><br>
					<p><b><font color = "black">Failed to Add Course! Make sure each field follows the format indicated!</font></b></p>
				</div>
			<%}%>
			<form id=form method="post" action="ProfBackPortalServlet">
             	<a href = "javascript:;" onclick="document.getElementById('form').submit();" class="back-button big page-back">
             		<input type = "hidden" name = "firstname" value = <%=firstname%>>
					<input type = "hidden" name = "lastname" value = <%=lastname%>>	
             	</a>
            </form>
		<div id="innerBody" class="page-region-content tiles">
			<br>
			<h1>Add Course</h1>
			<p>Please fill in all fields.</p>
			<p> Course (* must be in this format: ECON 101):</p>
			<form name="form1" method="get" action ="ProfAddCourseServlet" onsubmit= "return validateTextFields()">
			<p>
			    <input type="text" name="Course">
			</p>
			<p>Title:</p>
			<p>
			  <input type="text" name="Title">
			</p>
			<p>Section: (*must be exactly 3 characters in length)</p>
			<p>
			  <input type="text" name="Section">
			</p>
			<p>Term (*must be a number):</p>
			<p>
			  <input type="text" name="Term">
			</p>
			<p>Year (*must be a number):</p>
			<p>
			  <input type="text" name="Year">
			</p>
			<p>Instructor:</p>
			<p>
			  <input type="text" name="Instructor">
			</p>
			  <input type="submit" name="Submit" value="Submit">
			  <input type = "hidden" name = "firstname" value = <%=firstname%>>
			  <input type = "hidden" name = "lastname" value = <%=lastname%>>	
		  </form>
			<br>
			</div>
		</div>
				<div id="footer">
			&copy;UBC Electrical and Computer Engineering. Styled with <a
				href="http://metroui.org.ua">Metro UI CSS</a>
		</div>
	</div>
</body>
</html>